﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure;
using System.Data.Services.Client;

namespace AzureLogs
{
    public class Class1
    {
        public static void Main()
        {
            var accountName = "slv";
            var sharedKey = "xreonsqDRcpHaUBe0VrcgyzdAoBrNFFnu++ebohm70jVDyDWsEte7eAVtfp2EzOYRPo05qu2SW9lUC5ulXNShQ==";
            var account = new CloudStorageAccount(
                new StorageCredentialsAccountAndKey(accountName, sharedKey), true);
            //var account = CloudStorageAccount.DevelopmentStorageAccount;

            var dt = new DateTime(2012, 4, 18, 7, 0, 0); // Logs more recent than 1/28/2010 4PM

            var wadlog = new WADLogsTableContext(account.TableEndpoint.ToString(), account.Credentials);
            var query = from row in wadlog.WADLogsTable
                        where string.Compare(row.PartitionKey, "0" + dt.Ticks.ToString()) > 0 && row.DeploymentId == "b8c5a808be4b48ad85afabb0bc0c0f1d"
                        select row;

            //query.Where(r => r.Message.Contains("a")).Dump();
            var rows = query.Where(r => r.Message.Contains("8b28cf48-b639-430a-b5b8-ef6c18eb3e75"));

            foreach (var row in rows)
                Console.WriteLine(row.Message);
            //query.Dump();


        }
    }

}
